// stdx/rangex.rs
// CRITICAL: Range、RangeInclusive 与步长/rev 使用示例。

#[allow(dead_code)]
pub fn stdx_examples_rangex() {
    let r = 0..5;
    let sum: i32 = r.clone().sum();
    let ri = 0..=5;
    let rev: Vec<_> = (0..5).rev().collect();
    let _ = (sum, ri, rev);

    // CRITICAL: Range 基本操作
    let range = 1..10;
    let start = range.start;
    let end = range.end;
    let is_empty = range.is_empty();

    // CRITICAL: RangeInclusive
    let inclusive = 1..=10;
    let inc_start = inclusive.start();
    let inc_end = inclusive.end();
    let inc_is_empty = inclusive.is_empty();

    // CRITICAL: 步长迭代
    let step_by: Vec<i32> = (0..10).step_by(2).collect();

    // CRITICAL: 反向迭代
    let reversed: Vec<i32> = (0..5).rev().collect();

    // CRITICAL: 范围包含检查
    let contains_5 = (1..10).contains(&5);
    let contains_10 = (1..10).contains(&10); // false for exclusive
    let inc_contains_10 = (1..=10).contains(&10); // true for inclusive

    // CRITICAL: 范围映射
    let mapped: Vec<i32> = (1..5).map(|x| x * 2).collect();

    // CRITICAL: 范围过滤
    let filtered: Vec<i32> = (0..10).filter(|x| x % 2 == 0).collect();

    // CRITICAL: 范围 zip
    let zipped: Vec<(i32, i32)> = (1..4).zip(4..7).collect();

    let _ = (
        start,
        end,
        is_empty,
        inc_start,
        inc_end,
        inc_is_empty,
        step_by,
        reversed,
        contains_5,
        contains_10,
        inc_contains_10,
        mapped,
        filtered,
        zipped,
    );
}
